<?php

namespace app\common\service;

class BaseService
{
    protected $model;
    public function __construct()
    {
        $this->initialize();
    }

    public function initialize(){
    }

    public function getList($param = []){

        $list = $this->model->getList($this->getWhere($param),'id desc');
        $count = $this->model->where($this->getWhere($param))->whereNull('delete_time')->count();
        return [
            'data' => $list,
            'count' =>$count
        ];
    }

    public function getInfo($id){
        return $this->model->getInfo($id);
    }
    public function edit($data){
        $res = $this->model->edit($data);
        if($res){
            return success($res);
        }else{
            return error();
        }
    }
    public function delete($data){
        if(empty($data)){
            return error("id为空");
        }
        return $this->model->deleteAll((array)$data);
    }
    public function status($data){
        return $this->model->edit($data);
    }
    public function getWhere($param){
        return [];
    }
}